import { withRouter, Switch, Route, Redirect, HashRouter  } from 'react-router-dom'
import { getToken } from '@/utils/tools'
import AppMain from '@/pages/AppMain'
import NotFound from '@/pages/NotFound'
import Login from '@/pages/Login'
import './App.less'

const App = () => {
  return (
    <HashRouter>
      {/* <AppMain /> */}
      <Switch>
        {/* <Redirect exact from='/' to='/home' /> */}
        <Route path="/" exact render={
          () => getToken() ?
            <Redirect to="/app" />:<Redirect to={{pathname: '/login'}} />
        } />
        <Route path="/login" component={Login} />
        <Route path="/app" component={AppMain} />
        <Route component={NotFound} />
      </Switch>
    </HashRouter>
  )
}

export default withRouter(App)
